package cn.com.dhc.danlu.business.shopcar.typefactory;

import android.view.View;

import cn.com.dhc.danlu.R;
import cn.com.dhc.danlu.activity.delivery.order.viewholder.BaseViewHolder;
import cn.com.dhc.danlu.business.shopcar.bean.MerchBean;
import cn.com.dhc.danlu.business.shopcar.bean.PromotionBean;
import cn.com.dhc.danlu.business.shopcar.bean.SellerBean;
import cn.com.dhc.danlu.business.shopcar.callback.IClickCallback;
import cn.com.dhc.danlu.business.shopcar.callback.IMerchDataChangeCallback;
import cn.com.dhc.danlu.business.shopcar.callback.ISellerClickCallback;
import cn.com.dhc.danlu.business.shopcar.holder.MerchViewHolder;
import cn.com.dhc.danlu.business.shopcar.holder.PromotionViewHolder;
import cn.com.dhc.danlu.business.shopcar.holder.SellerViewHolder;


/**
 * author: 李一方(<a href="mailto:liyifang@danlu.com">liyifang@danlu.com</a>)<br/>
 * version: 1.0.0<br/>
 * since: 2017-02-14 15:12
 *
 * <p>
 * 购物车的 item 工厂
 * </p>
 */
public class ShopCarTypeFactory implements IShopCarTypeFactory {
    private static final int STORE_LAYOUT = R.layout.item_shopcar_seller;
    private static final int GOODS_LAYOUT = R.layout.item_shopcar_merch;
    private static final int PROMOTION_LAYOUT = R.layout.item_shopcar_promotion;

    @Override
    public int type(MerchBean merchBean) {
        return GOODS_LAYOUT;
    }

    @Override
    public int type(SellerBean sellerBean) {
        return STORE_LAYOUT;
    }

    @Override
    public int type(PromotionBean promotionBean) {
        return PROMOTION_LAYOUT;
    }

    @Override
    public BaseViewHolder createViewHolder(int type, View itemView, IClickCallback callback) {
        switch (type) {
            case STORE_LAYOUT:
                return new SellerViewHolder(itemView, (ISellerClickCallback) callback);

            case GOODS_LAYOUT:
                return new MerchViewHolder(itemView, (IMerchDataChangeCallback) callback);

            case PROMOTION_LAYOUT:
                return new PromotionViewHolder(itemView);

            default:
                return null;
        }
    }
}
